package com.scnu.hachimi.element;

import com.scnu.hachimi.manager.ResourcesManager;

import java.awt.*;

/**
 * 注意子弹类的x，y为中心坐标，不是左上角坐标
 */

public class Bullet extends ElementObject {
    private int speed;
    public int atk;
    private Direction direct;
    private Color color;
    public boolean isPlayer;

    public Bullet(String img, int x, int y, int width, int height, int speed, int atk, Direction direct, Color color, boolean isPlayer) {
        super(img, x, y, width, height);
        this.speed = speed;
        this.atk = atk;
        this.direct = direct;
        this.color = color;
        this.isPlayer = isPlayer;
    }

    @Override
    public void paintSelf(Graphics g, ResourcesManager rm) {
        g.setColor(color);
        g.fillOval(x - w / 2, y - h / 2, w, h);
    }

    @Override
    public Rectangle getRect() {
        return new Rectangle(x - w / 2, y - h / 2, w, h);
    }

    public void move() {
        switch (direct) {
            case UP:
                y -= speed;
                break;
            case DOWN:
                y += speed;
                break;
            case LEFT:
                x -= speed;
                break;
            case RIGHT:
                x += speed;
                break;
        }
    }
}
